package com.yc.thread.basic;

/**
 * @author zwei
 * @create 2024-07-14 14:38
 */
public class Test8_ReThrowInterruptException {
    public static void main(String[] args) throws InterruptedException {
        //当前线程
        Thread thread=Thread.currentThread();
        try {
            //检测当前线程是否被中断
            thread.interrupt(); //发出中断信号
            //线程休眠3秒
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            System.out.println(thread.getName()+"抛出interruptedException");
            System.out.println(thread.getName()+"做一些清理工作");
            //也可以将中断异常继续向上抛出
            throw e;
        }
        System.out.println("主程序还能正常运行吗？");
    }
}
